﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DemoObject;
using BusinessObjects;

public partial class Module_Photos_Controls_PhotoList : System.Web.UI.UserControl
{
    public string AlbumTextId { get; set; }
    public string AlbumName { get; set; }
    private const int PageSize = 16;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request["AlbumTextId"] != null)
            {
                AlbumTextId = Request["AlbumTextId"];
            }
            else AlbumTextId = "";
            int page = 1;
            if (Request["page"] != null)
                page = int.Parse(Request["page"]);
            HashSet<string> hs = new HashSet<string>();
            hs.Add("DisplayOrder ASC");
            int RowCount = 0;
            Response.Write(page);
            IList<TblAlbum> ls = TblAlbumRepository.CreateInstant().SelectListItem(null, "", "", true, null, page, PageSize, out RowCount, hs);
            rpt.DataSource = ls;
            rpt.DataBind();


            smartPager.PageSize = PageSize;
            smartPager.QueryStringKey = "page";
            smartPager.RowCount = RowCount;
            smartPager.UrlFormatString = UrlBuilder.UrlAlbumPaging(AlbumTextId);
            smartPager.Visible = RowCount > PageSize;
            TblAlbum item = TblAlbumRepository.CreateInstant().SelectOne(AlbumTextId);
            if (item != null)
            {
                SetTitle(item);
                AlbumName = item.Name;
            }


        }
    }
    void SetTitle(TblAlbum _item)
    {
        string title = _item.Name;
        string description = _item.Name;
        string keywords = _item.Name;
        MasterPage _page = this.Page.Master;
        HTT.Utility.WebUtility.SetPage(title, description, keywords, _page);
    }
}
